From: Paul Donald Date: Thu, 28 Nov 2024 02:43:33 +0000 (+0100) Subject: ddns-scripts: refactor get_uptime() and avoid cat in sub-shell X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22/%22https:/collectd.org/%22?a=commitdiff_plain;h=5b277eb855a40417304acdd849f5c526eb6c297f;p=feed%2Fpackages.git ddns-scripts: refactor get_uptime() and avoid cat in sub-shell no sub-shell is spawned to get uptime. Signed-off-by: Paul Donald --- diff --git a/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh b/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh index d64ad8c26b..297388a159 100644 --- a/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh +++ b/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh @@ -1210,9 +1210,9 @@ get_registered_ip() { get_uptime() { # $1 Variable to store result in - [ $# -ne 1 ] && write_log 12 "Error calling 'verify_host_port()' - wrong number of parameters" - local __UPTIME=$(cat /proc/uptime) - eval "$1=\"${__UPTIME%%.*}\"" + [ $# -ne 1 ] && write_log 12 "Error calling 'get_uptime()' - requires exactly 1 argument." + read -r uptime < /proc/uptime + eval "$1=\"${uptime%%.*}\"" } trap_handler() {